<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="./vue.global.js"></script>
    <style>
        .box{
            background-color: red;
        }
    </style>
</head>
<body>
    <div id="app">
        <my-head title="hello world" class="box" @click="handleClick"></my-head>
    </div>
    <script>
        let app = Vue.createApp({
            data(){
                return {
                    count: 10
                }
            },
            methods:{
                handleClick(ev){
                    console.log('点击了:' + ev.currentTarget)
                }
            }
        })

        app.component(
            'MyHead',
            {
                // $attrs也可以完成父子通信
                template: `
                <header>
                    <h2 v-bind:class="$attrs.class">attrs.class:{{$attrs.class}}</h2>
                    <ul v-bind:title="$attrs.title">
                        <li>首页</li>
                        <li>视频</li>
                        <li>音乐</li>
                    </ul>
                </header>
                `,
                inheritAttrs:false,
                mounted(){
                    // $attrs也可以完成父子通信
                    console.log(this.$attrs)
                }

            })

        let vm = app.mount('#app');
    </script>

</body>
</html>